using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentAttendanceDetailManager class is responsible for managing BO.StudentAttendanceDetail objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentAttendanceDetailManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentAttendanceDetail objects in the database.
        /// </summary>
        /// <returns>A list with all StudentAttendanceDetail from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentAttendanceDetailList GetList()
        {
            return StudentAttendanceDetailDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentAttendanceDetail from the database without its data.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceDetail in the database.</param>
        /// <returns>A StudentAttendanceDetail object when the AttKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceDetail GetItemByStudentProfileKey(long attKey, int StudentProfileKey)
        {
            return StudentAttendanceDetailDB.GetItemByStudentProfileKey(attKey, StudentProfileKey);
        }

        /// <summary>
        /// Gets a single StudentAttendanceDetail from the database without its data.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceDetail in the database.</param>
        /// <returns>A StudentAttendanceDetail object when the AttKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceDetail GetItem(long attKey)
        {
            return GetItem(attKey, false);
        }

        /// <summary>
        /// Gets a single StudentAttendanceDetail from the database.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceDetail in the database.</param>
        /// <param name="getStudentAttendanceDetailRecords">Determines whether to load all associated StudentAttendanceDetail records as well.</param>
        /// <returns>
        /// A StudentAttendanceDetail object when the AttKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceDetail GetItem(long attKey, bool getStudentAttendanceDetailRecords)
        {
            StudentAttendanceDetail myStudentAttendanceDetail = StudentAttendanceDetailDB.GetItem(attKey);
            return myStudentAttendanceDetail;
        }

        /// <summary>
        /// Saves a StudentAttendanceDetail in the database.
        /// </summary>
        /// <param name="myStudentAttendanceDetail">The StudentAttendanceDetail instance to save.</param>
        /// <returns>The new AttKey if the StudentAttendanceDetail is new in the database or the existing AttKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static long Save(StudentAttendanceDetail myStudentAttendanceDetail)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                long studentAttendanceDetailAttKey = StudentAttendanceDetailDB.Save(myStudentAttendanceDetail);

                //  Assign the StudentAttendanceDetail its new (or existing AttKey).
                myStudentAttendanceDetail.AttDetailKey = studentAttendanceDetailAttKey;

                myTransactionScope.Complete();

                return studentAttendanceDetailAttKey;
            }
        }

        /// <summary>
        /// Deletes a StudentAttendanceDetail from the database.
        /// </summary>
        /// <param name="myStudentAttendanceDetail">The StudentAttendanceDetail instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentAttendanceDetail myStudentAttendanceDetail)
        {
            return StudentAttendanceDetailDB.Delete(myStudentAttendanceDetail.AttKey);
        }

        #endregion

    }

}
